package com.xunua.gaud_map_demo;

import android.Manifest;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import com.gyf.immersionbar.ImmersionBar;

/**
 * @user XUNUA
 * @email xunua@outlook.com
 * @creat time 2020/5/9 14:29
 */
public abstract class BaseActivity extends AppCompatActivity {
    private static final String TAG = "BaseActivity";
    private final static int PERMISSION_REQUESTCODE=10086;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ImmersionBar.with(this)
                .statusBarDarkFont(true)//状态栏字体颜色
                .navigationBarColor(R.color.colorWhite)//导航栏颜色，不写默认黑色
                .navigationBarDarkIcon(true)//导航栏图标是深色，不写默认为亮色
                .init();//沉浸状态栏
        permission();
    }

    private void permission() {//获取权限
        ActivityCompat.requestPermissions(this, new String[]{
                Manifest.permission.ACCESS_COARSE_LOCATION,
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_NETWORK_STATE,
                Manifest.permission.ACCESS_WIFI_STATE,
                Manifest.permission.CHANGE_WIFI_STATE,
                Manifest.permission.READ_PHONE_STATE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
                Manifest.permission.BLUETOOTH,
                Manifest.permission.BLUETOOTH_ADMIN
        }, PERMISSION_REQUESTCODE);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode==PERMISSION_REQUESTCODE){
            for (int i = 0; i < permissions.length; i++) {
//                Log.e(TAG, "onRequestPermissionsResult: "+permissions[i]);
//                Log.e(TAG, "onRequestPermissionsResult: "+grantResults[i] );
            }
        }
    }
}
